package de.pernpas.calendar.entity;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

@PersistenceCapable
public class Event {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private Date date;
	
	@Persistent
	private String location;
	
	@Persistent
	private String eventName;
	
	@Persistent
	private Text description;
	
	@Persistent
	private Date created;
	
	@Persistent
	private Date modified;

	public Event(Date date, String location, String eventName, String description) {
		this.date = date;
		this.location = location;
		this.eventName = eventName;
		this.description = new Text(description);
	}

	public Key getKey() {
		return key;
	}

	public void setKey(Key key) {
		this.key = key;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getEventName() {
		return eventName;
	}

	public void setEventName(String eventName) {
		this.eventName = eventName;
	}

	public void setDescription(Text description) {
		this.description = description;
	}

	public Text getDescription() {
		return description;
	}
	
	public String toString(){
		String result ="";
		result = "Key: " + getKey().getId() + "\n" + 
				"Daet: " + getDate() + "\n" + 
				"Location: " + getLocation() + "\n" + 
				"Name: " + getEventName() + "\n" + 
				"Description: " + getDescription().getValue() + "\n" + 
				"Last modified: " + getModified(); 
		return result;
	}

	public void setModified(Date modified) {
		this.modified = modified;
	}

	public Date getModified() {
		return modified;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Date getCreated() {
		return created;
	}
}
